package com.liuyjy2.encryptDecrypt;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdScalarSerializer;
import com.liuyjy.base.common.util.AESUtil;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;

import java.io.IOException;
import java.util.Base64;

/**
 * @Author liuyjy
 * @Date 2025/2/20 9:42
 * @Description: 动态序列化器
 **/
public class DynamicCryptoSerializer extends JsonSerializer<Object> {
    @Override
    public void serialize(Object value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        // 加密逻辑，假设是简单的Base64编码
        String encrypt = AESUtil.encrypt((String) value);
        gen.writeString(encrypt);
    }
}
